package drops.dao;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;


/**
 * This class was autogenerated by Torque on:
 *
 * [Fri Mar 19 07:17:38 SGT 2010]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Patient
 */
public abstract class BasePatient extends BaseObject
{
    /** The Peer class */
    private static final PatientPeer peer =
        new PatientPeer();

        
    /** The value for the patientNumber field */
    private int patientNumber;
      
    /** The value for the patientFirstName field */
    private String patientFirstName;
      
    /** The value for the patientMiddleName field */
    private String patientMiddleName;
      
    /** The value for the patientLastName field */
    private String patientLastName;
      
    /** The value for the address field */
    private String address;
      
    /** The value for the contactNumber field */
    private String contactNumber;
      
    /** The value for the age field */
    private int age;
      
    /** The value for the occupation field */
    private String occupation;
      
    /** The value for the status field */
    private String status;
      
    /** The value for the complain field */
    private String complain;
  
    
    /**
     * Get the PatientNumber
     *
     * @return int
     */
    public int getPatientNumber()
    {
        return patientNumber;
    }

                                              
    /**
     * Set the value of PatientNumber
     *
     * @param v new value
     */
    public void setPatientNumber(int v) throws TorqueException
    {
    
                  if (this.patientNumber != v)
              {
            this.patientNumber = v;
            setModified(true);
        }
    
          
                                  
        // update associated DentalTransaction
        if (collDentalTransactions != null)
        {
            for (int i = 0; i < collDentalTransactions.size(); i++)
            {
                ((DentalTransaction) collDentalTransactions.get(i))
                    .setPatientNumber(v);
            }
        }
                                          
        // update associated Tooth
        if (collTooths != null)
        {
            for (int i = 0; i < collTooths.size(); i++)
            {
                ((Tooth) collTooths.get(i))
                    .setPatientNumber(v);
            }
        }
                      }
  
    /**
     * Get the PatientFirstName
     *
     * @return String
     */
    public String getPatientFirstName()
    {
        return patientFirstName;
    }

                        
    /**
     * Set the value of PatientFirstName
     *
     * @param v new value
     */
    public void setPatientFirstName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.patientFirstName, v))
              {
            this.patientFirstName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the PatientMiddleName
     *
     * @return String
     */
    public String getPatientMiddleName()
    {
        return patientMiddleName;
    }

                        
    /**
     * Set the value of PatientMiddleName
     *
     * @param v new value
     */
    public void setPatientMiddleName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.patientMiddleName, v))
              {
            this.patientMiddleName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the PatientLastName
     *
     * @return String
     */
    public String getPatientLastName()
    {
        return patientLastName;
    }

                        
    /**
     * Set the value of PatientLastName
     *
     * @param v new value
     */
    public void setPatientLastName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.patientLastName, v))
              {
            this.patientLastName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Address
     *
     * @return String
     */
    public String getAddress()
    {
        return address;
    }

                        
    /**
     * Set the value of Address
     *
     * @param v new value
     */
    public void setAddress(String v) 
    {
    
                  if (!ObjectUtils.equals(this.address, v))
              {
            this.address = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the ContactNumber
     *
     * @return String
     */
    public String getContactNumber()
    {
        return contactNumber;
    }

                        
    /**
     * Set the value of ContactNumber
     *
     * @param v new value
     */
    public void setContactNumber(String v) 
    {
    
                  if (!ObjectUtils.equals(this.contactNumber, v))
              {
            this.contactNumber = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Age
     *
     * @return int
     */
    public int getAge()
    {
        return age;
    }

                        
    /**
     * Set the value of Age
     *
     * @param v new value
     */
    public void setAge(int v) 
    {
    
                  if (this.age != v)
              {
            this.age = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Occupation
     *
     * @return String
     */
    public String getOccupation()
    {
        return occupation;
    }

                        
    /**
     * Set the value of Occupation
     *
     * @param v new value
     */
    public void setOccupation(String v) 
    {
    
                  if (!ObjectUtils.equals(this.occupation, v))
              {
            this.occupation = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Status
     *
     * @return String
     */
    public String getStatus()
    {
        return status;
    }

                        
    /**
     * Set the value of Status
     *
     * @param v new value
     */
    public void setStatus(String v) 
    {
    
                  if (!ObjectUtils.equals(this.status, v))
              {
            this.status = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Complain
     *
     * @return String
     */
    public String getComplain()
    {
        return complain;
    }

                        
    /**
     * Set the value of Complain
     *
     * @param v new value
     */
    public void setComplain(String v) 
    {
    
                  if (!ObjectUtils.equals(this.complain, v))
              {
            this.complain = v;
            setModified(true);
        }
    
          
              }
  
         
                                
            
    /**
     * Collection to store aggregation of collDentalTransactions
     */
    protected List collDentalTransactions;

    /**
     * Temporary storage of collDentalTransactions to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initDentalTransactions()
    {
        if (collDentalTransactions == null)
        {
            collDentalTransactions = new ArrayList();
        }
    }

    /**
     * Method called to associate a DentalTransaction object to this object
     * through the DentalTransaction foreign key attribute
     *
     * @param l DentalTransaction
     * @throws TorqueException
     */
    public void addDentalTransaction(DentalTransaction l) throws TorqueException
    {
        getDentalTransactions().add(l);
        l.setPatient((Patient) this);
    }

    /**
     * The criteria used to select the current contents of collDentalTransactions
     */
    private Criteria lastDentalTransactionsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getDentalTransactions(new Criteria())
     *
     * @throws TorqueException
     */
    public List getDentalTransactions() throws TorqueException
    {
        if (collDentalTransactions == null)
        {
            collDentalTransactions = getDentalTransactions(new Criteria(10));
        }
        return collDentalTransactions;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Patient has previously
     * been saved, it will retrieve related DentalTransactions from storage.
     * If this Patient is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getDentalTransactions(Criteria criteria) throws TorqueException
    {
        if (collDentalTransactions == null)
        {
            if (isNew())
            {
               collDentalTransactions = new ArrayList();
            }
            else
            {
                      criteria.add(DentalTransactionPeer.PATIENT_NUMBER, getPatientNumber() );
                      collDentalTransactions = DentalTransactionPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(DentalTransactionPeer.PATIENT_NUMBER, getPatientNumber());
                      if (!lastDentalTransactionsCriteria.equals(criteria))
                {
                    collDentalTransactions = DentalTransactionPeer.doSelect(criteria);
                }
            }
        }
        lastDentalTransactionsCriteria = criteria;

        return collDentalTransactions;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getDentalTransactions(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getDentalTransactions(Connection con) throws TorqueException
    {
        if (collDentalTransactions == null)
        {
            collDentalTransactions = getDentalTransactions(new Criteria(10), con);
        }
        return collDentalTransactions;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Patient has previously
     * been saved, it will retrieve related DentalTransactions from storage.
     * If this Patient is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getDentalTransactions(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collDentalTransactions == null)
        {
            if (isNew())
            {
               collDentalTransactions = new ArrayList();
            }
            else
            {
                       criteria.add(DentalTransactionPeer.PATIENT_NUMBER, getPatientNumber());
                       collDentalTransactions = DentalTransactionPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(DentalTransactionPeer.PATIENT_NUMBER, getPatientNumber());
                       if (!lastDentalTransactionsCriteria.equals(criteria))
                 {
                     collDentalTransactions = DentalTransactionPeer.doSelect(criteria, con);
                 }
             }
         }
         lastDentalTransactionsCriteria = criteria;

         return collDentalTransactions;
     }

                  
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Patient is new, it will return
     * an empty collection; or if this Patient has previously
     * been saved, it will retrieve related DentalTransactions from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Patient.
     */
    protected List getDentalTransactionsJoinPatient(Criteria criteria)
        throws TorqueException
    {
        if (collDentalTransactions == null)
        {
            if (isNew())
            {
               collDentalTransactions = new ArrayList();
            }
            else
            {
                            criteria.add(DentalTransactionPeer.PATIENT_NUMBER, getPatientNumber());
                            collDentalTransactions = DentalTransactionPeer.doSelectJoinPatient(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(DentalTransactionPeer.PATIENT_NUMBER, getPatientNumber());
                        if (!lastDentalTransactionsCriteria.equals(criteria))
            {
                collDentalTransactions = DentalTransactionPeer.doSelectJoinPatient(criteria);
            }
        }
        lastDentalTransactionsCriteria = criteria;

        return collDentalTransactions;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collTooths
     */
    protected List collTooths;

    /**
     * Temporary storage of collTooths to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initTooths()
    {
        if (collTooths == null)
        {
            collTooths = new ArrayList();
        }
    }

    /**
     * Method called to associate a Tooth object to this object
     * through the Tooth foreign key attribute
     *
     * @param l Tooth
     * @throws TorqueException
     */
    public void addTooth(Tooth l) throws TorqueException
    {
        getTooths().add(l);
        l.setPatient((Patient) this);
    }

    /**
     * The criteria used to select the current contents of collTooths
     */
    private Criteria lastToothsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getTooths(new Criteria())
     *
     * @throws TorqueException
     */
    public List getTooths() throws TorqueException
    {
        if (collTooths == null)
        {
            collTooths = getTooths(new Criteria(10));
        }
        return collTooths;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Patient has previously
     * been saved, it will retrieve related Tooths from storage.
     * If this Patient is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getTooths(Criteria criteria) throws TorqueException
    {
        if (collTooths == null)
        {
            if (isNew())
            {
               collTooths = new ArrayList();
            }
            else
            {
                      criteria.add(ToothPeer.PATIENT_NUMBER, getPatientNumber() );
                      collTooths = ToothPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(ToothPeer.PATIENT_NUMBER, getPatientNumber());
                      if (!lastToothsCriteria.equals(criteria))
                {
                    collTooths = ToothPeer.doSelect(criteria);
                }
            }
        }
        lastToothsCriteria = criteria;

        return collTooths;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getTooths(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getTooths(Connection con) throws TorqueException
    {
        if (collTooths == null)
        {
            collTooths = getTooths(new Criteria(10), con);
        }
        return collTooths;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Patient has previously
     * been saved, it will retrieve related Tooths from storage.
     * If this Patient is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getTooths(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collTooths == null)
        {
            if (isNew())
            {
               collTooths = new ArrayList();
            }
            else
            {
                       criteria.add(ToothPeer.PATIENT_NUMBER, getPatientNumber());
                       collTooths = ToothPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(ToothPeer.PATIENT_NUMBER, getPatientNumber());
                       if (!lastToothsCriteria.equals(criteria))
                 {
                     collTooths = ToothPeer.doSelect(criteria, con);
                 }
             }
         }
         lastToothsCriteria = criteria;

         return collTooths;
     }

                  
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Patient is new, it will return
     * an empty collection; or if this Patient has previously
     * been saved, it will retrieve related Tooths from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Patient.
     */
    protected List getToothsJoinPatient(Criteria criteria)
        throws TorqueException
    {
        if (collTooths == null)
        {
            if (isNew())
            {
               collTooths = new ArrayList();
            }
            else
            {
                            criteria.add(ToothPeer.PATIENT_NUMBER, getPatientNumber());
                            collTooths = ToothPeer.doSelectJoinPatient(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(ToothPeer.PATIENT_NUMBER, getPatientNumber());
                        if (!lastToothsCriteria.equals(criteria))
            {
                collTooths = ToothPeer.doSelectJoinPatient(criteria);
            }
        }
        lastToothsCriteria = criteria;

        return collTooths;
    }
                            


          
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
              fieldNames.add("PatientNumber");
              fieldNames.add("PatientFirstName");
              fieldNames.add("PatientMiddleName");
              fieldNames.add("PatientLastName");
              fieldNames.add("Address");
              fieldNames.add("ContactNumber");
              fieldNames.add("Age");
              fieldNames.add("Occupation");
              fieldNames.add("Status");
              fieldNames.add("Complain");
              fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
          if (name.equals("PatientNumber"))
        {
                return new Integer(getPatientNumber());
            }
          if (name.equals("PatientFirstName"))
        {
                return getPatientFirstName();
            }
          if (name.equals("PatientMiddleName"))
        {
                return getPatientMiddleName();
            }
          if (name.equals("PatientLastName"))
        {
                return getPatientLastName();
            }
          if (name.equals("Address"))
        {
                return getAddress();
            }
          if (name.equals("ContactNumber"))
        {
                return getContactNumber();
            }
          if (name.equals("Age"))
        {
                return new Integer(getAge());
            }
          if (name.equals("Occupation"))
        {
                return getOccupation();
            }
          if (name.equals("Status"))
        {
                return getStatus();
            }
          if (name.equals("Complain"))
        {
                return getComplain();
            }
          return null;
    }
    
    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
          if (name.equals(PatientPeer.PATIENT_NUMBER))
        {
                return new Integer(getPatientNumber());
            }
          if (name.equals(PatientPeer.PATIENT_FIRST_NAME))
        {
                return getPatientFirstName();
            }
          if (name.equals(PatientPeer.PATIENT_MIDDLE_NAME))
        {
                return getPatientMiddleName();
            }
          if (name.equals(PatientPeer.PATIENT_LAST_NAME))
        {
                return getPatientLastName();
            }
          if (name.equals(PatientPeer.ADDRESS))
        {
                return getAddress();
            }
          if (name.equals(PatientPeer.CONTACT_NUMBER))
        {
                return getContactNumber();
            }
          if (name.equals(PatientPeer.AGE))
        {
                return new Integer(getAge());
            }
          if (name.equals(PatientPeer.OCCUPATION))
        {
                return getOccupation();
            }
          if (name.equals(PatientPeer.STATUS))
        {
                return getStatus();
            }
          if (name.equals(PatientPeer.COMPLAIN))
        {
                return getComplain();
            }
          return null;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
            if (pos == 0)
        {
                return new Integer(getPatientNumber());
            }
              if (pos == 1)
        {
                return getPatientFirstName();
            }
              if (pos == 2)
        {
                return getPatientMiddleName();
            }
              if (pos == 3)
        {
                return getPatientLastName();
            }
              if (pos == 4)
        {
                return getAddress();
            }
              if (pos == 5)
        {
                return getContactNumber();
            }
              if (pos == 6)
        {
                return new Integer(getAge());
            }
              if (pos == 7)
        {
                return getOccupation();
            }
              if (pos == 8)
        {
                return getStatus();
            }
              if (pos == 9)
        {
                return getComplain();
            }
              return null;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
          save(PatientPeer.getMapBuilder()
                .getDatabaseMap().getName());
      }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
       * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
       *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
          try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
      }

      /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
      /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
          if (!alreadyInSave)
        {
            alreadyInSave = true;


  
            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    PatientPeer.doInsert((Patient) this, con);
                    setNew(false);
                }
                else
                {
                    PatientPeer.doUpdate((Patient) this, con);
                }
            }

                                      
                
            if (collDentalTransactions != null)
            {
                for (int i = 0; i < collDentalTransactions.size(); i++)
                {
                    ((DentalTransaction) collDentalTransactions.get(i)).save(con);
                }
            }
                                          
                
            if (collTooths != null)
            {
                for (int i = 0; i < collTooths.size(); i++)
                {
                    ((Tooth) collTooths.get(i)).save(con);
                }
            }
                          alreadyInSave = false;
        }
      }


                          
      /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param  patientNumber ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
            setPatientNumber(((NumberKey) key).intValue());
        }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
            setPatientNumber(Integer.parseInt(key));
        }

  
    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
          return SimpleKey.keyFor(getPatientNumber());
      }

 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
       * It then fills all the association collections and sets the
     * related objects to isNew=true.
       */
      public Patient copy() throws TorqueException
    {
        return copyInto(new Patient());
    }
  
    protected Patient copyInto(Patient copyObj) throws TorqueException
    {
          copyObj.setPatientNumber(patientNumber);
          copyObj.setPatientFirstName(patientFirstName);
          copyObj.setPatientMiddleName(patientMiddleName);
          copyObj.setPatientLastName(patientLastName);
          copyObj.setAddress(address);
          copyObj.setContactNumber(contactNumber);
          copyObj.setAge(age);
          copyObj.setOccupation(occupation);
          copyObj.setStatus(status);
          copyObj.setComplain(complain);
  
                    copyObj.setPatientNumber(0);
                                                                  
                                      
                
        List v = getDentalTransactions();
        for (int i = 0; i < v.size(); i++)
        {
            DentalTransaction obj = (DentalTransaction) v.get(i);
            copyObj.addDentalTransaction(obj.copy());
        }
                                                  
                
        v = getTooths();
        for (int i = 0; i < v.size(); i++)
        {
            Tooth obj = (Tooth) v.get(i);
            copyObj.addTooth(obj.copy());
        }
                    
        return copyObj;
    }

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public PatientPeer getPeer()
    {
        return peer;
    }

    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Patient:\n");
        str.append("PatientNumber = ")
           .append(getPatientNumber())
           .append("\n");
        str.append("PatientFirstName = ")
           .append(getPatientFirstName())
           .append("\n");
        str.append("PatientMiddleName = ")
           .append(getPatientMiddleName())
           .append("\n");
        str.append("PatientLastName = ")
           .append(getPatientLastName())
           .append("\n");
        str.append("Address = ")
           .append(getAddress())
           .append("\n");
        str.append("ContactNumber = ")
           .append(getContactNumber())
           .append("\n");
        str.append("Age = ")
           .append(getAge())
           .append("\n");
        str.append("Occupation = ")
           .append(getOccupation())
           .append("\n");
        str.append("Status = ")
           .append(getStatus())
           .append("\n");
        str.append("Complain = ")
           .append(getComplain())
           .append("\n");
        return(str.toString());
    }
}
